#!/usr/bin/python2
# -*- coding: utf-8; mode: Python; indent-tabs-mode: t; tab-width: 4; python-indent: 4 -*-

# Copyright (C) 2012  Olga Yakovleva <yakovleva.o.v@gmail.com>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import sys
import re

if __name__=="__main__":
	words=set()
	with open(sys.argv[1],"rb") as f_in:
		with open(sys.argv[2],"wb") as f_out:
			for line in f_in:
				entry=line.strip()
				if (not entry) or entry.startswith(";"):
					continue
				tokens=re.sub('["()]',"",entry).split()
				if tokens[0] not in words:
					f_out.write(" ".join(tokens[0]))
					f_out.write("\n")
					f_out.write(" ".join(tokens[2:]))
					f_out.write("\n")
					words.add(tokens[0])
